package com.qf.wangqing.sportsnews.adapter.headline;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Shader;

import com.squareup.picasso.Transformation;

/**
 * Created by ShenHao on 2016/12/16.
 */

public class CircleTranslation implements Transformation{
    @Override
    public Bitmap transform(Bitmap source) {

        Bitmap target=Bitmap.createBitmap(source.getWidth(),source.getHeight(), Bitmap.Config.ARGB_8888);
        Paint paint = new Paint();
        paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        new Canvas(target).drawCircle(source.getWidth()/2,source.getHeight()/2,source.getWidth()/2,paint);

        source.recycle();
        return target;
    }

    @Override
    public String key() {
        return "circle";
    }
}
